package com.example.demo;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private ITestService testService;

    @GetMapping("/insert")
    public void insert(){
        JSONObject jo  = new JSONObject();
        jo.put("name","张三");
        jo.put("age",20);
        MyTest t = new MyTest();
        t.setProp(jo);
        testService.save(t);
    }


    @GetMapping("/update")
    public void update(){
        MyTest one = testService.lambdaQuery()
                .eq(MyTest::getId, 1)
                .one();
        JSONObject prop = one.getProp();
        prop.put("password","11111");
        testService.removeById(1);
        MyTest t = new MyTest();
        t.setProp(prop);
        testService.save(t);

    }
}
